<?php
	global $current_controller;
	$tool_buttons = array
	(
		'list_button' => array
		(
			'image'=>'btnNew.gif', 
			'text'=>LANG_ADD, 
			'url'=>'/'.$this->name.'/add/'.$this->data[system_table_id].'/'.$this->data[row_id]
		)
	);	
	$this->helpers->html->form('/'.$this->name.'/edit/'.$this->data[system_table_id].'/'.$this->data[row_id]);
	$this->helpers->htmlx->MenuText1(LANG_SYSTEM_PERMISSIONS_ROWS.': '.LANG_SYSTEM_PERMISSIONS_ROWS_EXPLANATION, "edit.gif");
	$this->helpers->toolbars->Toolbar($tool_buttons);
	echo "<table class='grid' cellspacing = '1'>";
   		echo"<tr>";
		$this->helpers->htmlx->td(ucfirst(LANG_ROLE), ' class="gridHeader" width=""');
		$this->helpers->htmlx->td(ucfirst(LANG_ALLOW_CHILDS), ' class="gridHeader" width="" align = center');
	    $this->helpers->htmlx->td(ucfirst(LANG_VIEW), ' class="gridHeader" width="" align = center');
		$this->helpers->htmlx->td(ucfirst(LANG_EDIT), ' class="gridHeader" width="" align = center');
		$this->helpers->htmlx->td(ucfirst(LANG_DELETE), ' class="gridHeader" width="" align = center');
		$this->helpers->htmlx->td(ucfirst(LANG_ACTIONS), ' class="gridHeader" width="" align = center');
	    echo"</tr>";
    	$i=1;
    	foreach ($this->data[permissions] as $permission)
    	{
    		if ($i%2==1) 
    		{
    			$cellStyle = 'gridCell1';
    		}
    		else 
    		{
    			$cellStyle = 'gridCell2';
    		}
    		echo "<tr>";
                echo "<td class='$cellStyle'>".$permission[role_name]."</td>"; 	
                echo "<td class='$cellStyle' align='center'>";
	    			$this->helpers->htmlx->checkBox('permission['.$permission[id].'][child]', 1, $permission[child], '');   		
	    		echo "</td>";  
        		echo "<td class='$cellStyle' align='center'>";
	    			$this->helpers->htmlx->checkBox('permission['.$permission[id].'][view]', 1, $permission[view], 'id="view'.$permission[id].'" onclick="document.getElementById(\'edit'.$permission[id].'\').checked=false"');   		
	    		echo "</td>";  
	    		echo "<td class='$cellStyle' align='center'>";
	    			$this->helpers->htmlx->checkBox('permission['.$permission[id].'][edit]', 1, $permission[edit], 'id="edit'.$permission[id].'" onclick="document.getElementById(\'view'.$permission[id].'\').checked=true"');   		
	    		echo "</td>";  
	    	    echo "<td class='$cellStyle' align='center'>";
	    			$this->helpers->htmlx->checkBox('permission['.$permission[id].'][delete]', 1, $permission[delete]);   		
	    		echo "</td>";  
	    		echo "<td class='$cellStyle' align='center'>";
				    $this->helpers->html->link("/".$this->name.'/delete/'.$permission[id], '<img src="/./'.THEMES.SEPARATOR.$current_controller->theme.'/images/btnDelete.gif">', 'class="buttons"', 'class="buttons"');
				echo "</td>";
	    		$this->helpers->htmlx->hidden('permission['.$permission[id].'][id]', $permission[id]); 
            echo "</tr>";
    		$i++;
    		$table_name = $permission[system_table_name];
    	}
	echo "</table>";
	$this->helpers->htmlx->submitTable('submit',$_SESSION[back_url]);
	//$this->helpers->htmlx->submitTable('submit',$this->name.'/edit/'.$this->data[system_table_id].'/'.$this->data[row_id]);
	echo "</form>";
?>